package com.yy.smartBI.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 图形类型枚举
 *
 */
public enum ChartTypeEnum {


    LINE("Line", "折线图"),
    AXIS("Axis", "柱状图"),

    RAIDER("Raider", "雷达图"),
    AOTU("AOTU", "凹凸图"),
    PUBU("PUBU", "瀑布图"),
    DUIDIEARE("DUIDIEARE", "堆叠面积图"),
    JBDUIDIEARE("JBDUIDIEARE", "渐变堆叠面积图"),
    BIGARE("BIGARE", "大数据量面积图");


    private final String type;

    private final String value;

    ChartTypeEnum(String type, String value) {
        this.type = type;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static ChartTypeEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (ChartTypeEnum anEnum : ChartTypeEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getText() {
        return type;
    }
}
